<?
ob_start();
include("common/header.html");
include("common/left.html");
$out_html=ob_get_contents();
ob_end_clean();
include("common/page.php");
if(!$_SESSION['memberID']){exit("<script>window.location='dlogin.html'</script>");}
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:10;
$op=$_REQUEST['op']?$_REQUEST["op"]:date("Y-m-d",strtotime("-1 month"));
$ed=$_REQUEST['ed']?$_REQUEST["ed"]:date("Y-m-d");
$oper=$opid=$list=$ids=array();
$sel="select son_id from pft_member_relationship where parent_id=".$_SESSION['memberID']." and son_id_type=0 and status=0";
$GLOBALS['le']->query($sel);
while($row=$GLOBALS['le']->fetch_assoc()){
	$ids[]=$row['son_id'];
}
// 导出
if($_REQUEST['act']=='Export'){
	$pageSize = 999999;
	$currentPage = 1;
}
if($ids){
	$sel=" from pft_member_journal j left join pft_member m on j.fid=m.id where j.fid in (".implode(",",$ids).") and m.status=0 and j.dtype=3 and rectime between '".$op." 00:00:00' and '".$ed." 23:59:59' ";
	$GLOBALS['le']->query("select m.dname,j.dmoney,j.lmoney,j.daction,j.rectime,j.opid".$sel."order by rectime DESC limit ".($currentPage-1)*$pageSize.",".$pageSize);
	while($row=$GLOBALS['le']->fetch_assoc()){
		if($row['daction']==0){
			$row['add']=$row['dmoney']/100;
		}
		else{
			$row['redu']=$row['dmoney']/100;
		}
		$list[]=$row;
		if($row['opid'] && !in_array($row['opid'],$opid)){$opid[]=$row['opid'];}
	}
	$GLOBALS['le']->query("select count(*) tt ".$sel);
	$GLOBALS['le']->fetch_assoc();
	$total=$GLOBALS['le']->f("tt");
	$GLOBALS['le']->query("select sum(j.dmoney) am ".$sel." and j.daction=0");
	$GLOBALS['le']->fetch_assoc();
	$all=$GLOBALS['le']->f("am");
	$sel="select id,dname from pft_member where id in (".implode(",",$opid).")";
	$GLOBALS['le']->query($sel);
	while($row=$GLOBALS['le']->fetch_assoc()){
		$oper[$row['id']]=$row['dname'];
	}
}
include("rrecord_e.html");
echo $out_html;
include("tpl/rrecord.html");
include("common/footer.html");?>